<template>
  <div id="app">
    <nav>
      <router-link to="/">首页</router-link>
      <router-link to="/public-activities">公开活动列表</router-link>
      <router-link v-if="isAuthenticated && role === 'admin'" to="/activity-management">活动管理</router-link>
      <router-link v-if="isAuthenticated" to="/user">用户信息</router-link>
      <router-link v-if="!isAuthenticated" to="/login">登录</router-link>
    </nav>
    <router-view />
  </div>
</template>

<script>
export default {
  computed: {
    isAuthenticated() {
      return !!localStorage.getItem('role');
    },
    role() {
      return localStorage.getItem('role');
    }
  }
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

nav {
  padding: 30px;
}

nav a {
  font-weight: bold;
  color: #2c3e50;
}

nav a.router-link-exact-active {
  color: #42b983;
}
</style>
